<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
  <title>summernote</title>
  <!-- include jquery -->
  <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> 

  <!-- include libraries BS3 -->
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
  <script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" />

  <!-- include codemirror (codemirror.css, codemirror.js, xml.js, formatting.js)-->
  <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.min.css" />
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/blackboard.min.css">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.min.css">
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.min.js"></script>

  <!-- include summernote -->
  <link rel="stylesheet" href="../dist/summernote.css">

  <script type="text/javascript" src="../dist/summernote.js"></script>
  <script type="text/javascript" src="../lang/summernote-ko-KR.js"></script>
  <script type="text/javascript" src="../plugin/summernote-ext-hint.js"></script>

  <script type="text/javascript">
    $(document).ready(function () {
      $('.summernote').summernote({
        height: 200,
        plugin: {
          hint: {
            loadEmoji: function (data) {
              this.emoji = Object.keys(data);
              this.emojiLink = data;
            },

            load: function ($popover) {
              var self = this;
              $.getJSON('https://api.github.com/emojis', function (data) {
                self.loadEmoji(data);
              });
            },

            content: function (item) {
              var url = this.emojiLink[item];
              if (url) {
                return $('<img />').attr('src', url).css({width: 20})[0];
              }
              return '';
            },

            template: function (item) {
              var content = this.emojiLink[item];
              return '<img src="' + content + '" width="20" /> :' + item + ':';
            },

            match: /\B:([\-+\w]+)$/,

            search: function (keyword, callback) {
              callback($.grep(this.emoji, function (item) {
                return item.indexOf(keyword)  === 0;
              }));
            }
          }
        }
      });
    });
  </script>
</head>
<body>
<textarea class="summernote">Type text start with ":". For example, :) or :+1:.</textarea>
</body>
</html>
